import {createStore , applyMiddleware, compose} from 'redux'
import {combineReducers} from 'redux-immutable'
import thunk from 'redux-thunk'
import { reducer as headerReducer } from '@/components/Header/store'
import { reducer as navLeftReducer } from '@/components/NavLeft/store'
import { reducer as mainTabReducer } from '@/components/MainTab/store'
import { reducer as mainBodyReducer } from '@/components/MainBody/store'
import { reducer as loginReducer } from '@/components/Login/store'
import { reducer as loadingReducer}  from '@/components/Loading/store'
import { reducer as homeReducer}  from '@/pages/Home/store'

import reducer from './reducer'

combineReducers({
    main: reducer,
})
const composeEnhancers =
    typeof window === 'object' &&
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
        window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
            // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
        }) : compose;

const enhancer = composeEnhancers(
    applyMiddleware(thunk),
    // other store enhancers if any
);
const store = createStore(
    combineReducers({
        main: reducer,
        header: headerReducer,
        navLeft: navLeftReducer,
        mainTab: mainTabReducer,
        mainBody: mainBodyReducer,
        login: loginReducer,
        loading: loadingReducer,
        home: homeReducer
    }),
    enhancer

)

export {store}